<template>
  <div class="header_container">
    <!-- 导航面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item v-for="(item,index) in $route.meta" :key="index">{{item}}</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 首页|退出 -->
    <el-dropdown @command="handleCommand" menu-align="start"  >
      <img class="avator"  src="../../assets/images/avatar.png"/>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="home">首页</el-dropdown-item>
        <el-dropdown-item command="logout">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  methods: {
    handleCommand(command) {
      if (command == 'home') {
        this.$router.push('/home')
      } else {
        // 清空token
        window.localStorage.clear()
        // 跳转到登录页
        this.$router.push('/login')
        // 退出登录成功
        this.$message.success('退出成功')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.header_container {
  background-color: #eff2f7;
  width: 96%;
  height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;

}
.avator {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.el-dropdown-menu__item {
  text-align: center;
}
</style>